﻿using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using ProgrammingEducationSystem.Models;

namespace ProgrammingEducationSystem.DbConfig
{
    public class AppDbCtx : IdentityDbContext<User,Role,string>
    {
        public AppDbCtx(DbContextOptions<AppDbCtx> options)
         : base(options)
        {
        }

        public DbSet<Class> Classes { get; set; }
        public DbSet<ClassRoom> ClassRooms { get; set; }
        public DbSet<Course> Courses { get; set; }
        public DbSet<CourseHour> CourseHours { get; set; }
        public DbSet<CourseType> CourseTypes { get; set; }
        public DbSet<LearnSource> LearnSources { get; set; }
        public DbSet<StuAndClass> StuAndClasses { get; set; }

        protected override void OnModelCreating(ModelBuilder builder)
        {
            builder.Entity<Role>().HasData(
                new Role() { 
                    Name = "STUDENT",
                    NormalizedName = "STUDENT"
                },
                new Role()
                {
                    Name = "TEACHER",
                    NormalizedName = "TEACHER"
                },
                new Role()
                {
                    Name = "ADMIN",
                    NormalizedName = "ADMIN"
                }
                );

            base.OnModelCreating(builder);
        }
    }
}